package com.tinusgraglin.enclusiv.ui

import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.tinusgraglin.enclusiv.datalayer.repos.ArticleRepo
import com.tinusgraglin.enclusiv.datalayer.repos.GlobalPrefDataRepo
import com.tinusgraglin.enclusiv.datalayer.repos.UserRepo
import com.tinusgraglin.enclusiv.ui.viewmodel.*

class EnclusivViewModelFactory : ViewModelProvider.Factory {
    override fun <T : ViewModel> create(modelClass: Class<T>): T {
        return when (modelClass) {
            SignInActivityViewModel::class.java ->
                SignInActivityViewModel(GlobalPrefDataRepo.get(), UserRepo.get()) as T
            SignUpActivityViewModel::class.java ->
                SignUpActivityViewModel(UserRepo.get()) as T
            MainActivityViewModel::class.java ->
                MainActivityViewModel(ArticleRepo.get(), UserRepo.get()) as T
            ArticleActivityViewModel::class.java ->
                ArticleActivityViewModel(UserRepo.get()) as T
            NewArticleViewModel::class.java ->
                NewArticleViewModel(UserRepo.get(), ArticleRepo.get()) as T
            else -> throw IllegalArgumentException("Unexpected model class: $modelClass")
        }
    }
}